load("data.RData") #load data
library(weights) #for using weights in statistical tests

#treatment effects for each DV
wtd.t.test(data$AA_Constitutional[data$treatment==4],data$AA_Constitutional[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])
wtd.t.test(data$AA_Preference[data$treatment==4],data$AA_Preference[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])
wtd.t.test(data$SCOTUS_Legit[data$treatment==4],data$SCOTUS_Legit[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])
wtd.t.test(data$SCOTUS_DecMk[data$treatment==4],data$SCOTUS_DecMk[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])
wtd.t.test(data$SCOTUS_Understands[data$treatment==4],data$SCOTUS_Understands[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])
wtd.t.test(data$Presidential_Vote[data$treatment==4],data$Presidential_Vote[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])

#Figure of main findings
lo1 <- wtd.t.test(data$AA_Constitutional[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]-qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
hi1 <- wtd.t.test(data$AA_Constitutional[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]+qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
lo2 <- wtd.t.test(data$AA_Preference[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]-qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
hi2 <- wtd.t.test(data$AA_Preference[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]+qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
lo3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]-qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
hi3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]+qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
lo4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]-qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
hi4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]+qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
lo5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]-qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
hi5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]+qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
lo8 <- wtd.t.test(data$Presidential_Vote[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]-qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
hi8 <- wtd.t.test(data$Presidential_Vote[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][2]+qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==5],weight = data$weight5[data$treatment==5])[[3]][4]
lo10 <- wtd.t.test(data$AA_Constitutional[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]-qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
hi10 <- wtd.t.test(data$AA_Constitutional[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]+qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
lo11 <- wtd.t.test(data$AA_Preference[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]-qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
hi11 <- wtd.t.test(data$AA_Preference[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]+qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
lo12 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]-qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
hi12 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]+qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
lo13 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]-qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
hi13 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]+qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
lo14 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]-qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
hi14 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]+qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
lo17 <- wtd.t.test(data$Presidential_Vote[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]-qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
hi17 <- wtd.t.test(data$Presidential_Vote[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][2]+qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4],weight = data$weight4[data$treatment==4])[[3]][4]
par(mar=c(5.1,9.6,4.1,2.1))
plot(c(wtd.t.test(data$AA_Preference[data$treatment==5],
                  weight = data$weight5[data$treatment==5])[[3]][2],
       wtd.t.test(data$AA_Constitutional[data$treatment==5],
                  weight = data$weight5[data$treatment==5])[[3]][2],
       wtd.t.test(data$SCOTUS_Legit[data$treatment==5],
                  weight = data$weight5[data$treatment==5])[[3]][2],
       wtd.t.test(data$SCOTUS_DecMk[data$treatment==5],
                  weight = data$weight5[data$treatment==5])[[3]][2],
       wtd.t.test(data$SCOTUS_Understands[data$treatment==5],
                  weight = data$weight5[data$treatment==5])[[3]][2],
       wtd.t.test(data$Presidential_Vote[data$treatment==5],
                  weight = data$weight5[data$treatment==5])[[3]][2]),
     c(7:6,4:1)-.1,
     pch=19,xlim=c(2.326021,4.537117),ylim=c(.9,7.6),
     col="gray",yaxt="n",xlab="Estimate",ylab="",
     main="Views of Policy and Court, by Control and Treatment Group")
segments(x0=c(lo2,lo1,lo3,lo4,lo5,lo8),
         y0=c(7:6,4:1)-.1,
         x1=c(hi2,hi1,hi3,hi4,hi5,hi8),
         y1=c(7:6,4:1)-.1,
         col="gray")
points(c(wtd.t.test(data$AA_Preference[data$treatment==4],
                    weight = data$weight4[data$treatment==4])[[3]][2],
         wtd.t.test(data$AA_Constitutional[data$treatment==4],
                    weight = data$weight4[data$treatment==4])[[3]][2],
         wtd.t.test(data$SCOTUS_Legit[data$treatment==4],
                    weight = data$weight4[data$treatment==4])[[3]][2],
         wtd.t.test(data$SCOTUS_DecMk[data$treatment==4],
                    weight = data$weight4[data$treatment==4])[[3]][2],
         wtd.t.test(data$SCOTUS_Understands[data$treatment==4],
                    weight = data$weight4[data$treatment==4])[[3]][2],
         wtd.t.test(data$Presidential_Vote[data$treatment==4],
                    weight = data$weight4[data$treatment==4])[[3]][2]),
       c(7:6,4:1)+.1,
       pch=19)    
segments(x0=c(lo11,lo10,lo12,lo13,lo14,lo17),
         y0=c(7:6,4:1)+.1,
         x1=c(hi11,hi10,hi12,hi13,hi14,hi17),
         y1=c(7:6,4:1)+.1)
axis(2,at=c(1:4,6:7),labels=c("Relation to Vote","Empathatic Institution",
                              "Law-Driven Institution",
                              "Support for Jurisdiction","Policy Support",
                              "Policy Acceptance"),
     las=2)
legend("topright",legend=c("Treatment","Control"),pch=19,lty=1,col=c("black","gray"))
axis(2,at=4.5,labels="Court-Related Views",tick=F,las=2,font=4)
axis(2,at=7.5,labels="Policy-Related Views",tick=F,las=2,font=4)
abline(h=5,lty=2)

#Figure of treatment effects
lo1 <- wtd.t.test(data$AA_Constitutional[data$treatment==4],data$AA_Constitutional[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]-qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4],data$AA_Constitutional[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
hi1 <- wtd.t.test(data$AA_Constitutional[data$treatment==4],data$AA_Constitutional[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]+qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4],data$AA_Constitutional[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
lo2 <- wtd.t.test(data$AA_Preference[data$treatment==4],data$AA_Preference[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]-qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4],data$AA_Preference[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
hi2 <- wtd.t.test(data$AA_Preference[data$treatment==4],data$AA_Preference[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]+qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4],data$AA_Preference[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
lo3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4],data$SCOTUS_Legit[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4],data$SCOTUS_Legit[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
hi3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4],data$SCOTUS_Legit[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4],data$SCOTUS_Legit[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
lo4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4],data$SCOTUS_DecMk[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4],data$SCOTUS_DecMk[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
hi4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4],data$SCOTUS_DecMk[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4],data$SCOTUS_DecMk[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
lo5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4],data$SCOTUS_Understands[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4],data$SCOTUS_Understands[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
hi5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4],data$SCOTUS_Understands[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4],data$SCOTUS_Understands[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
lo6 <- wtd.t.test(data$Presidential_Vote[data$treatment==4],data$Presidential_Vote[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]-qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4],data$Presidential_Vote[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
hi6 <- wtd.t.test(data$Presidential_Vote[data$treatment==4],data$Presidential_Vote[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]+qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4],data$Presidential_Vote[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][4]
par(mar=c(5.1,9.6,4.1,2.1))
plot(c(wtd.t.test(data$AA_Constitutional[data$treatment==4],data$AA_Constitutional[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1],
       wtd.t.test(data$AA_Preference[data$treatment==4],data$AA_Preference[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1],
       wtd.t.test(data$SCOTUS_Legit[data$treatment==4],data$SCOTUS_Legit[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1],
       wtd.t.test(data$SCOTUS_DecMk[data$treatment==4],data$SCOTUS_DecMk[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1],
       wtd.t.test(data$SCOTUS_Understands[data$treatment==4],data$SCOTUS_Understands[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1],
       wtd.t.test(data$Presidential_Vote[data$treatment==4],data$Presidential_Vote[data$treatment==5],weight=data$weight4[data$treatment==4],weighty = data$weight5[data$treatment==5])[[3]][1]),
     c(7:6,4:1),
     pch=19,xlim=c(-1.125857,1.125857),ylim=c(.9,7.6),yaxt="n",
     xlab="Causal Effect",ylab="",
     col=c("black","black","gray","black","black","black"),
     main="Causal Effects of Treatment")
segments(x0=c(lo1,lo2,lo3,lo4,lo5,lo6),
         y0=c(7:6,4:1),
         x1=c(hi1,hi2,hi3,hi4,hi5,hi6),
         y1=c(7:6,4:1),
         col=c("black","black","gray","black","black","black"))
axis(2,at=c(1:4,6:7),labels=c("Relation to Vote","Empathatic Institution",
                              "Law-Driven Institution",
                              "Support for Jurisdiction","Policy Support",
                              "Policy Acceptance"),
     las=2)
axis(2,at=4.5,labels="Court-Related Views",tick=F,las=2,font=4)
axis(2,at=7.5,labels="Policy-Related Views",tick=F,las=2,font=4)
abline(v=0,lty=2)

#Treatment effects by PID
wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Democrat"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])
wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Republican"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])
wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Democrat"],data$AA_Preference[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])
wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Republican"],data$AA_Preference[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])
wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])
wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])
wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])
wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])
wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])
wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])
wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Democrat"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])
wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Republican"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])

#Plot of effects by PID
red2<-alpha("red",.25)
red1<-alpha("red",NA)
blue2<-alpha("blue",.25)
blue1<-alpha("blue",NA)
lo1 <- wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Democrat"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]-qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Democrat"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
hi1 <- wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Democrat"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]+qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Democrat"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
lo2 <- wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Democrat"],data$AA_Preference[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]-qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Democrat"],data$AA_Preference[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
hi2 <- wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Democrat"],data$AA_Preference[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]+qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Democrat"],data$AA_Preference[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
lo3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
hi3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
lo4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
hi4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
lo5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
hi5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
lo6 <- wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Democrat"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]-qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Democrat"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
hi6 <- wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Democrat"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]+qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Democrat"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][4]
par(mar=c(5.1,9.6,4.1,2.1))
plot(c(wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Democrat"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1],
       wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Democrat"],data$AA_Preference[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1],
       wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1],
       wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1],
       wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Democrat"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1],
       wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Democrat"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Democrat"],weight=data$weight4[data$treatment==4 & data$pid3=="Democrat"],weighty = data$weight5[data$treatment==5 & data$pid3=="Democrat"])[[3]][1]),
     c(7:6,4:1)+.1,
     pch=15,xlim=c(-1.125857,1.125857),ylim=c(.9,7.6),yaxt="n",
     xlab="Causal Effect",ylab="",
     col=c(blue1,blue1,blue2,blue2,blue2,blue2),
     main="Causal Effects of Treatment, by Respondent Partisanship")
segments(x0=c(lo1,lo2,lo3,lo4,lo5,lo6),
         y0=c(7:6,4:1)+.1,
         x1=c(hi1,hi2,hi3,hi4,hi5,hi6),
         y1=c(7:6,4:1)+.1,
         col=c(blue1,blue1,blue2,blue2,blue2,blue2))
axis(2,at=c(1:4,6:7),labels=c("Relation to Vote","Empathatic Institution",
                              "Law-Driven Institution",
                              "Support for Jurisdiction","Policy Support",
                              "Policy Acceptance"),
     las=2)
axis(2,at=4.5,labels="Court-Related Views",tick=F,las=2,font=4)
axis(2,at=7.5,labels="Policy-Related Views",tick=F,las=2,font=4)
abline(v=0,lty=2)
legend("topleft",legend=c("Democrats","Republicans"),pch=c(15,17),lty=2,col=c(blue1,red1))
lo1 <- wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Republican"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]-qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Republican"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
hi1 <- wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Republican"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]+qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Republican"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
lo2 <- wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Republican"],data$AA_Preference[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]-qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Republican"],data$AA_Preference[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
hi2 <- wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Republican"],data$AA_Preference[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]+qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Republican"],data$AA_Preference[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
lo3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
hi3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
lo4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
hi4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
lo5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
hi5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
lo6 <- wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Republican"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]-qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Republican"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
hi6 <- wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Republican"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]+qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Republican"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][4]
points(c(wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$pid3=="Republican"],data$AA_Constitutional[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1],
         wtd.t.test(data$AA_Preference[data$treatment==4 & data$pid3=="Republican"],data$AA_Preference[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1],
         wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Legit[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1],
         wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_DecMk[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1],
         wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$pid3=="Republican"],data$SCOTUS_Understands[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1],
         wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$pid3=="Republican"],data$Presidential_Vote[data$treatment==5 & data$pid3=="Republican"],weight=data$weight4[data$treatment==4 & data$pid3=="Republican"],weighty = data$weight5[data$treatment==5 & data$pid3=="Republican"])[[3]][1]),
       c(7:6,4:1)-.1,
       pch=17,
       col=c(red2,red2,red2,red1,red1,red1))
segments(x0=c(lo1,lo2,lo3,lo4,lo5,lo6),
         y0=c(7:6,4:1)-.1,
         x1=c(hi1,hi2,hi3,hi4,hi5,hi6),
         y1=c(7:6,4:1)-.1,
         col=c(red2,red2,red2,red1,red1,red1))

#create new weights variable
data$weight[data$treatment==5] <- data$weight5[data$treatment==5]
data$weight[data$treatment==4] <- data$weight4[data$treatment==4]

#set reference treatment category to control group
data$treatment <- relevel(factor(data$treatment),ref="5")

#treatment effects, overall and by subgroups
summary(mod1<-lm(AA_Constitutional~treatment,data=data,weights=weight))
summary(mod2<-lm(AA_Preference~treatment,data=data,weights=weight))
summary(mod3<-lm(SCOTUS_Legit~treatment,data=data,weights=weight))
summary(mod4<-lm(SCOTUS_DecMk~treatment,data=data,weights=weight))
summary(mod5<-lm(SCOTUS_Understands~treatment,data=data,weights=weight))
summary(mod6<-lm(Presidential_Vote~treatment,data=data,weights=weight))

summary(mod1<-lm(AA_Constitutional~treatment,data=data[data$pid3=="Democrat",],weights=weight))
summary(mod2<-lm(AA_Preference~treatment,data=data[data$pid3=="Democrat",],weights=weight))
summary(mod3<-lm(SCOTUS_Legit~treatment,data=data[data$pid3=="Democrat",],weights=weight))
summary(mod4<-lm(SCOTUS_DecMk~treatment,data=data[data$pid3=="Democrat",],weights=weight))
summary(mod5<-lm(SCOTUS_Understands~treatment,data=data[data$pid3=="Democrat",],weights=weight))
summary(mod6<-lm(Presidential_Vote~treatment,data=data[data$pid3=="Democrat",],weights=weight))

summary(mod1<-lm(AA_Constitutional~treatment,data=data[data$pid3=="Republican",],weights=weight))
summary(mod2<-lm(AA_Preference~treatment,data=data[data$pid3=="Republican",],weights=weight))
summary(mod3<-lm(SCOTUS_Legit~treatment,data=data[data$pid3=="Republican",],weights=weight))
summary(mod4<-lm(SCOTUS_DecMk~treatment,data=data[data$pid3=="Republican",],weights=weight))
summary(mod5<-lm(SCOTUS_Understands~treatment,data=data[data$pid3=="Republican",],weights=weight))
summary(mod6<-lm(Presidential_Vote~treatment,data=data[data$pid3=="Republican",],weights=weight))

summary(mod1<-lm(AA_Constitutional~treatment,data=data[data$race=="Other",],weights=weight))
summary(mod2<-lm(AA_Preference~treatment,data=data[data$race=="Other",],weights=weight))
summary(mod3<-lm(SCOTUS_Legit~treatment,data=data[data$race=="Other",],weights=weight))
summary(mod4<-lm(SCOTUS_DecMk~treatment,data=data[data$race=="Other",],weights=weight))
summary(mod5<-lm(SCOTUS_Understands~treatment,data=data[data$race=="Other",],weights=weight))
summary(mod6<-lm(Presidential_Vote~treatment,data=data[data$race=="Other",],weights=weight))

summary(mod1<-lm(AA_Constitutional~treatment,data=data[data$race=="White",],weights=weight))
summary(mod2<-lm(AA_Preference~treatment,data=data[data$race=="White",],weights=weight))
summary(mod3<-lm(SCOTUS_Legit~treatment,data=data[data$race=="White",],weights=weight))
summary(mod4<-lm(SCOTUS_DecMk~treatment,data=data[data$race=="White",],weights=weight))
summary(mod5<-lm(SCOTUS_Understands~treatment,data=data[data$race=="White",],weights=weight))
summary(mod6<-lm(Presidential_Vote~treatment,data=data[data$race=="White",],weights=weight))


#t.tests by minority status
wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="White"],data$AA_Constitutional[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])
wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="Other"],data$AA_Constitutional[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])
wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="White"],data$AA_Preference[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])
wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="Other"],data$AA_Preference[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])
wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="White"],data$SCOTUS_Legit[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])
wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="Other"],data$SCOTUS_Legit[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])
wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="White"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])
wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="Other"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])
wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="White"],data$SCOTUS_Understands[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])
wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="Other"],data$SCOTUS_Understands[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])
wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="White"],data$Presidential_Vote[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])
wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="Other"],data$Presidential_Vote[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])

#plot of effects by minority status
orange2<-alpha("darkorange",.25)
orange1<-alpha("darkorange",NA)
green2<-alpha("darkgreen",.25)
green1<-alpha("darkgreen",NA)
lo1 <- wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="Other"],data$AA_Constitutional[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]-qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="Other"],data$AA_Constitutional[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
hi1 <- wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="Other"],data$AA_Constitutional[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]+qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="Other"],data$AA_Constitutional[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
lo2 <- wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="Other"],data$AA_Preference[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]-qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="Other"],data$AA_Preference[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
hi2 <- wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="Other"],data$AA_Preference[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]+qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="Other"],data$AA_Preference[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
lo3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="Other"],data$SCOTUS_Legit[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="Other"],data$SCOTUS_Legit[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
hi3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="Other"],data$SCOTUS_Legit[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="Other"],data$SCOTUS_Legit[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
lo4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="Other"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="Other"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
hi4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="Other"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="Other"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
lo5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="Other"],data$SCOTUS_Understands[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="Other"],data$SCOTUS_Understands[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
hi5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="Other"],data$SCOTUS_Understands[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="Other"],data$SCOTUS_Understands[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
lo6 <- wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="Other"],data$Presidential_Vote[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]-qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="Other"],data$Presidential_Vote[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
hi6 <- wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="Other"],data$Presidential_Vote[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]+qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="Other"],data$Presidential_Vote[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][4]
par(mar=c(5.1,9.6,4.1,2.1))
plot(c(wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="Other"],data$AA_Constitutional[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1],
       wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="Other"],data$AA_Preference[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1],
       wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="Other"],data$SCOTUS_Legit[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1],
       wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="Other"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1],
       wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="Other"],data$SCOTUS_Understands[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1],
       wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="Other"],data$Presidential_Vote[data$treatment==5 & data$race=="Other"],weight=data$weight4[data$treatment==4 & data$race=="Other"],weighty = data$weight5[data$treatment==5 & data$race=="Other"])[[3]][1]),
     c(7:6,4:1)+.1,
     pch=19,xlim=c(-1.125857,1.125857),ylim=c(.9,7.6),yaxt="n",
     xlab="Causal Effect",ylab="",
     col=c(orange1,orange2,orange2,orange2,orange2,orange1),
     main="Causal Effects of Treatment, by Minority Status")
segments(x0=c(lo1,lo2,lo3,lo4,lo5,lo6),
         y0=c(7:6,4:1)+.1,
         x1=c(hi1,hi2,hi3,hi4,hi5,hi6),
         y1=c(7:6,4:1)+.1,
         col=c(orange1,orange2,orange2,orange2,orange2,orange1))
axis(2,at=c(1:4,6:7),labels=c("Relation to Vote","Empathatic Institution",
                              "Law-Driven Institution",
                              "Support for Jurisdiction","Policy Support",
                              "Policy Acceptance"),
     las=2)
axis(2,at=4.5,labels="Court-Related Views",tick=F,las=2,font=4)
axis(2,at=7.5,labels="Policy-Related Views",tick=F,las=2,font=4)
abline(v=0,lty=2)
legend("topleft",legend=c("Minorities","Majority"),pch=19,lty=2,col=c(orange1,green1))
lo1 <- wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="White"],data$AA_Constitutional[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]-qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="White"],data$AA_Constitutional[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
hi1 <- wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="White"],data$AA_Constitutional[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]+qnorm(.975)*wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="White"],data$AA_Constitutional[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
lo2 <- wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="White"],data$AA_Preference[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]-qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="White"],data$AA_Preference[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
hi2 <- wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="White"],data$AA_Preference[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]+qnorm(.975)*wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="White"],data$AA_Preference[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
lo3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="White"],data$SCOTUS_Legit[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="White"],data$SCOTUS_Legit[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
hi3 <- wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="White"],data$SCOTUS_Legit[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="White"],data$SCOTUS_Legit[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
lo4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="White"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="White"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
hi4 <- wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="White"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="White"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
lo5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="White"],data$SCOTUS_Understands[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]-qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="White"],data$SCOTUS_Understands[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
hi5 <- wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="White"],data$SCOTUS_Understands[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]+qnorm(.975)*wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="White"],data$SCOTUS_Understands[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
lo6 <- wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="White"],data$Presidential_Vote[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]-qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="White"],data$Presidential_Vote[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
hi6 <- wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="White"],data$Presidential_Vote[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]+qnorm(.975)*wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="White"],data$Presidential_Vote[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][4]
par(mar=c(5.1,9.6,4.1,2.1))
points(c(wtd.t.test(data$AA_Constitutional[data$treatment==4 & data$race=="White"],data$AA_Constitutional[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1],
         wtd.t.test(data$AA_Preference[data$treatment==4 & data$race=="White"],data$AA_Preference[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1],
         wtd.t.test(data$SCOTUS_Legit[data$treatment==4 & data$race=="White"],data$SCOTUS_Legit[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1],
         wtd.t.test(data$SCOTUS_DecMk[data$treatment==4 & data$race=="White"],data$SCOTUS_DecMk[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1],
         wtd.t.test(data$SCOTUS_Understands[data$treatment==4 & data$race=="White"],data$SCOTUS_Understands[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1],
         wtd.t.test(data$Presidential_Vote[data$treatment==4 & data$race=="White"],data$Presidential_Vote[data$treatment==5 & data$race=="White"],weight=data$weight4[data$treatment==4 & data$race=="White"],weighty = data$weight5[data$treatment==5 & data$race=="White"])[[3]][1]),
       c(7:6,4:1)-.1,
       pch=19,
       col=c(green2,green2,green1,green1,green1,green2))
segments(x0=c(lo1,lo2,lo3,lo4,lo5,lo6),
         y0=c(7:6,4:1)-.1,
         x1=c(hi1,hi2,hi3,hi4,hi5,hi6),
         y1=c(7:6,4:1)-.1,
         col=c(green2,green2,green1,green1,green1,green2))

#difference-in-difference estimates
summary(mod1<-lm(AA_Constitutional~treatment*pid3,data=data[data$pid3!="Independent",],weights=weight))
summary(mod2<-lm(AA_Preference~treatment*pid3,data=data[data$pid3!="Independent",],weights=weight))
summary(mod3<-lm(SCOTUS_Legit~treatment*pid3,data=data[data$pid3!="Independent",],weights=weight))
summary(mod4<-lm(SCOTUS_DecMk~treatment*pid3,data=data[data$pid3!="Independent",],weights=weight))
summary(mod5<-lm(SCOTUS_Understands~treatment*pid3,data=data[data$pid3!="Independent",],weights=weight))
summary(mod6<-lm(Presidential_Vote~treatment*pid3,data=data[data$pid3!="Independent",],weights=weight))
summary(mod1<-lm(AA_Constitutional~treatment*race,data=data,weights=weight))
summary(mod2<-lm(AA_Preference~treatment*race,data=data,weights=weight))
summary(mod3<-lm(SCOTUS_Legit~treatment*race,data=data,weights=weight))
summary(mod4<-lm(SCOTUS_DecMk~treatment*race,data=data,weights=weight))
summary(mod5<-lm(SCOTUS_Understands~treatment*race,data=data,weights=weight))
summary(mod6<-lm(Presidential_Vote~treatment*race,data=data,weights=weight))